package com.yugao.fintech.antelope.base.model.module.auth;

import com.alibaba.ttl.TransmittableThreadLocal;

import java.util.Objects;


public class LoginUserHolder {
    private static final TransmittableThreadLocal<LoginUser> ttl = new TransmittableThreadLocal<>();

    public static LoginUser get() {
        LoginUser loginUser = ttl.get();
        if (Objects.isNull(loginUser)) {
            loginUser = new LoginUser();
            ttl.set(loginUser);
        }
        return loginUser;
    }

    public static void set(LoginUser user) {
        ttl.set(user);
    }

    public static void remove() {
        ttl.remove();
    }
}
